package org.levi.demo.mybatis.plugin.dao;

import org.apache.ibatis.annotations.Param;
import org.levi.demo.mybatis.plugin.annotation.DataAuth;
import org.levi.demo.mybatis.plugin.annotation.DataPermission;
import org.levi.demo.mybatis.plugin.entity.UserEntity;

import java.io.IOException;
import java.util.List;

public interface UserDao {

    //查询所有用户
    @DataAuth(permissions = {@DataPermission(tableName = "user", resourceId = "2")})
    public List<UserEntity> findAll() throws IOException;

    //多条件组合查询：演示if
//    public List<UserEntity> findByCondition(UserEntity user);

    @DataAuth(permissions = {@DataPermission(tableName = "user", resourceId = "1")})
    public List<UserEntity> findByCondition(@Param("username") String username, @Param("id") int id);

    @DataAuth(permissions = {@DataPermission(tableName = "user", tableAlias = "u", resourceId = "1"),
                             @DataPermission(tableName = "u_order", tableAlias = "t", resourceId = "11")})
    public List<UserEntity> findUserOrder(@Param("userId") int userId);

    //多值查询：演示foreach
    public List<UserEntity> findByIds(int[] ids);
}
